<?php
if ($_GET['type'] == 'msg') {
	if (preg_match('/^[\x{4e00}-\x{9fa5}A-Za-z0-9_]{1,50}+$/u', $_GET["err_z"]) | preg_match('/^[\x{4e00}-\x{9fa5}A-Za-z0-9_]{1,50}+$/u', $_GET["err_o"]) | preg_match('/^[\x{4e00}-\x{9fa5}A-Za-z0-9_]{1,50}+$/u', $_GET["err_lic_z"]) | preg_match('/^[\x{4e00}-\x{9fa5}A-Za-z0-9_]{1,50}+$/u', $_GET["err_lic_o"]) | preg_match('/^[\x{4e00}-\x{9fa5}A-Za-z0-9_]{1,50}+$/u', $_GET["err_lic_t"])) {
		include "islogin.php";
		if ($is_log == "1") {
			setcookie("nickname", $nickname, time() - 180000, "/");
			setcookie("check", $checkcode, time() - 180000, "/");
			echo "1";
		} else {
			include "getuid.php";
			include 'setting.php';
			$con = mysqli_connect($sqldatabase, $sqlusername, $sqlpassword, $sqltable);
			mysqli_query($con, 'set names utf8');
			mysqli_query($con,"UPDATE softset SET err_z = '" . $_GET["err_z"] . "' , err_o = '" . $_GET["err_o"] . "' , err_z_lic = '" . $_GET["err_lic_z"] . "' , err_o_lic = '" . $_GET["err_lic_o"] . "' , err_t_lic = '" . $_GET["err_lic_t"] . "' WHERE uid = '" . $uid . "'");
			echo "0";
			mysqli_close($con);
		}
	}
} else if ($_GET['type'] == 'name') {
	if (preg_match('/^[\x{4e00}-\x{9fa5}A-Za-z0-9_]{1,15}+$/u', $_GET["nickname"])) {
		include "islogin.php";
		if ($is_log == "1") {
			setcookie("nickname", $nickname, time() - 180000, "/");
			setcookie("check", $checkcode, time() - 180000, "/");
			echo "1";
		} else {
			include "getuid.php";
			include 'setting.php';
			$con = mysqli_connect($sqldatabase, $sqlusername, $sqlpassword, $sqltable);
			mysqli_query($con, 'set names utf8');
			setcookie("nickname", $_GET["nickname"], time() + 1800, "/");
			mysqli_query($con,"UPDATE userdata SET nickname = '" . $_GET["nickname"] . "' WHERE uid = '" . $uid . "'");
			echo "0";
			mysqli_close($con);
		}
	}
}
else
{echo 'BAD REQUEST!PLEASE TRY AGAIN!';}
?>